package com.mydemo.ssl;

import javax.net.ssl.HandshakeCompletedEvent;
import javax.net.ssl.HandshakeCompletedListener;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;

public class MyHandshakeCompletedListener implements HandshakeCompletedListener {
    private String protocol;
    private String cipherSuite;
    private String peerName;
    @Override
    public void handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent) {
        SSLSession session = handshakeCompletedEvent.getSession();
        this.protocol = session.getProtocol();
        this.cipherSuite = session.getCipherSuite();
        try {
            this.peerName = session.getPeerPrincipal().getName();
        } catch (SSLPeerUnverifiedException e) {
        }
    }

    public String getProtocol() {
        return protocol;
    }

    public String getCipherSuite() {
        return cipherSuite;
    }

    public String getPeerName() {
        return peerName;
    }
}
